<?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>           				
<div id="content-header">
    <h1><?php echo __d('system','Content Management');?></h1>
</div>
<div class="container-fluid">
<div class="row-fluid">
	<div class="span12">	
    <?php echo $this->element('toolbar');?>	            							
		<div class="widget-box widget-content-no-padding">
            <div class="widget-content widget-content-two">
                <table class="table table-bordered data-table table-striped wd-hover-btn">
					<thead>
						<tr>
							<th style="text-align:left"><?php echo  __d('system', 'Title'); ?></th>
							<th width="12%"><?php echo  __d('system', 'Priority'); ?></th>
							<th style="text-align:left" width="18%"><?php echo  __d('system', 'Catalog'); ?></th>
							<th width="8%">Translate</th>
							<th width="12%"><?php echo  __d('system', 'Action'); ?></th>
						</tr>
					</thead>
					<tbody>
                        <?php
                        
                        $defaultLanguage = Router::defaultLanguage();
                        $_queries = array('continue' => $this->request->here(false));
                        ?> 
                        <?php foreach ($listNodes as $node) :  ?>                                            
						  <tr>            
                                <?php if (isset($_displayFields['title'])): ?>       
                                    <td>
                                        <a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit', $node['Node']['node_type_id'], $node['Node']['id'], '?' => $_queries));?>"> 
                                            <span class="wd-asideleft"><?php echo $node['Node']['title']; ?></span></a>
                                    </td>
                                <?php endif; ?>
                                <td><span class="priority"><?php echo $node['Node']['field_priority']; ?></span></td>
                                <?php if (isset($_displayFields['node_type_id'])): ?>       
                                    <td>
                                        <a href="#">  <?php echo $node['NodeType']['name']; ?></a>
                                    </td>
                                    <?php endif; ?>    
                                <td>
                                    <?php if (isset($_translateMaps)): ?>
                                        <ul class="wd-laguage">
                                            <?php
                                                foreach (Configure::read('Languages') as $_language) {
                                                    if ($_language['code'] === $defaultLanguage) {
                                                        continue;
                                                    } 
                                                    if(empty($_language['path'])){
                                                        $flags = 'flags_default.png';                                                
                                                    }
                                                    else{$flags = $_language['path'];}                                                                                        
                                                ?>
                                                
                                                <li><?php  echo $this->Html->link($this->Html->image('/img/' .$flags), array('plugin'=>'node','controller'=>'node','action' => 'translate', $node['Node']['id'], $_language['code'], '?' => $_queries), array(
                                                            'class' => 'tip-top', 'escape' => false, 'title' => $_language['name']));?></li>           
                                                <?php }?>
                                        </ul>
                                        <?php endif; ?>  
                                </td>
                                
                                <td>
                                    <ul class="wd-link-control">
                                        <li><a href="<?php echo $this->Html->url(array('plugin'=>'node','controller' => 'node', 'action' => 'edit', $node['Node']['node_type_id'], $node['Node']['id'], '?' => $_queries));?>" class="btn btn-mini">
                                                <i class="icon-edit"></i> <?php echo __d('system','Edit');?></a></li>
                                        <li><a href="#<?php echo $node['Node']['id']?>" data-toggle="modal" class="btn btn-mini"><i class="icon-remove"></i> <?php echo __d('system','Delete');?></a></li>                            
                                    </ul>
                                </td>
                            </tr>                                                   
                    <?php endforeach?>                        
					</tbody>
                  <?php foreach ($listNodes as $node) : ?> 
            			 	<div id="<?php echo $node['Node']['id']?>" class="modal hide">
            					<div class="modal-header">
            						<button data-dismiss="modal" class="close" type="button">×</button>
            						<h3><?php echo __d('system','Alert');?></h3>
            					</div>
            					<div class="modal-body">
            						<p><?php echo __d('system','Are you sure delete');?> “<?php echo $node['Node']['title']?>”?</p>
            					</div>
            					<div class="modal-footer">
            						<a data-dismiss="modal" class="btn" href="#"><?php echo __d('system','Cancel');?></a>
                                    <?php echo $this->Html->link(__d('system','Delete'), array('plugin'=>'node','controller' => 'node','action' => 'delete', '?' => array_merge($_queries, array('keys' => array($node['Node']['id'])))), array('title' => false, 'class' => 'btn btn-danger','data-dismiss='=>'modal')); ?>                        
            					</div>
            				</div>  
                <?php endforeach?>                    
				</table>
            </div>								
			</div>
		</div>
	</div>	
</div>
<?php         
echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
echo $this->Form->end();
?>